package com.hxh.tess4j.phone;

import com.alibaba.fastjson.JSONObject;
import com.hxh.tess4j.util.OkhttpUtil;
import lombok.Data;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.List;

/**
 * @author huangxunhui
 * Date: Created in 2019-04-16 17:00
 * Utils: Intellij Idea
 * Description:
 */
public class GetPhoneNum {

    public static void get() throws IOException {

        File file = new File("/Users/code/IdeaProjects/tess4j/src/main/resources/phone/phone.txt");
        Writer out = new FileWriter(file);

        String url = "http://dc.zwqlcm.com/admin/user/listUserInfo";
        GetForm getForm = new GetForm();

        for (int i = 0; i < 1246 ; i++) {
            getForm.setPageNo(1);
            String ret = OkhttpUtil.postJsonParams(url, JSONObject.toJSONString(getForm));
            UserListVo userListVo = JSONObject.parseObject(ret, UserListVo.class);
            userListVo.getInfos().forEach(userVo ->{
                try {
                    out.write(userVo.getPhone()+",");
                } catch (IOException e) {
                    e.printStackTrace();
                }
            });
        }

    }


    public static void main(String[] args) throws IOException {
        get();
    }
}

@Data
class GetForm{

    private Integer pageNo;

    private String token = "fecb97f443de003e20cfd5447607fdba";

    private Integer operatorId = 12;

}

@Data
class UserListVo{

    private List<UserVo> infos;

}

@Data
class UserVo{

    private String phone;

}

